package com.ymatou.app.seller.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;
/**
*添加直播商品接口Call
*FreeMaker Template自动生成代码
*/
public class ActivityTabProductListCall extends YmatouBaseCall{
	private static String opurl ="api/Product/ActivityTabProductList?";
	public ActivityTabProductListCall() {
		super(EnvSetup.getSystemUrl("seller_app"),opurl,"GET","PARAM");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	/**
	 * 获取Status
	 * 
	 * @return Status
	 */
	public int getStatus() {
		int status = 500;
		try {
			JSONObject jo = new JSONObject(getReturnData());			
			status=jo.getInt("Status");		
		} catch (Exception e) {
			e.printStackTrace();
		}
		return status;
	}
	
	
	/**
	 * 获取Result
	 * 
	 * @return Result
	 */
	public JSONObject getResult(){
		JSONObject jo = null;
		try {
			jo = new JSONObject(getReturnData()).getJSONObject("Result");			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return jo;	
	}
	
	/**
	 * 获取返回报文的第一个商品id
	 * 
	 * @return productId
	 */
	public String getProductId() {
		String productId = null ;
		try {
			JSONObject jo = getResult();	
			JSONObject 	productInLists=jo.getJSONArray("ShangouProductInLists").getJSONObject(0);
			productId=productInLists.getString("ProductId");		
		} catch (Exception e) {
			e.printStackTrace();
		}
		return productId;
	}
}